<template>
  <div>
    <hd-login :loginStyle="loginStyle" :fun="beforeLogin"></hd-login>
    <wl-customer></wl-customer>
    <Modal class="modal-style" v-model="modal2" :footer-hide="true" :closable="false" :mask-closable="false">
      <p>系统升级中！</p>
      <p>将于2023年11月27日恢复，</p>
      <p>给您带了不便，请谅解！</p>
    </Modal>
  </div>
</template>

<script>
import { mapActions } from 'vuex'
import { getOfficeInfo } from '@/api/record'
import WlCustomer from '@/views/pages/home/components/customer'

export default {
  components: { WlCustomer },
  data () {
    return {
      loginStyle: {
        backgroundImage: 'url(https://oss.shengshitong.com/yqdata/house/Wl/login.png)'
      },
      modal2: true
    }
  },
  mounted () {

  },
  methods: {
    ...mapActions([
      'setUserInfo',
      'getUserInfo'
    ]),
    getOfficeInfoAction () {
      getOfficeInfo().then(res => {
        if (res.data.errcode === 0) {
          // let severUserInfo = this.$common.xeUtils.clone(this.$store.state.user.severUserInfo)
          // const param = {
          //   ...severUserInfo.data, // 原登录信息
          //   record_number: res.data.data.record_number, // 全宗号
          //   office_code: res.data.data.office_code // 单位编码
          // }
          // severUserInfo.data = param
          // this.setUserInfo(severUserInfo)
          // console.log('缓存', window.localStorage)
          // console.log(res.data.data.company_type, '存储')
          window.localStorage.removeItem('record_number')
          window.localStorage.removeItem('company_type')
          window.localStorage.setItem('record_number', res.data.data.record_number)
          window.localStorage.setItem('company_type', res.data.data.company_type)
        }
      })
    },
    async beforeLogin () {
      let rest = await this.getUserInfo()
      if (rest.errcode === 0) {
        let _this = this
        setTimeout(function () {
          _this.getOfficeInfoAction()
        }, 500)
        return true
      } else {
        this.$Message.error('获取用户信息失败')
        return false
      }
    }
  }
}
</script>
<style lang="less" scoped>
/deep/ .login{
  position: absolute;
}
.modal-style :nth-child(1){
  font-weight: bold;
  font-size: 20px;
}
</style>
